from model import Model
from density_generator import DensityGen
from bsmart import BSmart
from random import uniform
from ghmm import HMMOpen, Alphabet, SequenceSet


#randomly generation of models
n_models = 4


alphabet=['a','b','c','d','e','f','g','h','i','l']
b = BSmart(alphabet)

aprioriGenerator=DensityGen()
aprioriGenerator.generate(1,n_models,0,0)
for count in range(n_models):
    #Randomly generates a model:
    n_states = int(uniform(2,7))
    transitionGenerator=DensityGen()
    transitionGenerator.generate(n_states,n_states, 0,0)
    emissionGenerator=DensityGen()
    emissionGenerator.generate(n_states,len(alphabet),3,3)
    startGenerator=DensityGen()
    startGenerator.generate(1, n_states, 0,0)
    m =b.createModel(transitionGenerator.getAllProbabilities(),
                  emissionGenerator.getAllProbabilities() ,
                  startGenerator.getProbability(0))
    b.addModel(m);
    b.addModelProbability(count, aprioriGenerator.getProbability(0)[count] )

#b.saveModels() #this instruction is commented to leave some human checks ;-)